package com.qingcheng.consumer;

import com.qingcheng.service.page.ItemService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.UnsupportedEncodingException;


//商品下架,对应队列接受消息后,将商品的对应的商品详情页删除
public class GoodsDeleteItemConsumer implements MessageListener {

//    @Reference
//    private SpuService spuService;
//
//    @Value("${pagePath}")
//    private String pagePath;

    @Autowired
    private ItemService itemService;

    public void onMessage(Message message) {
        String spuId = null;
        try {
            spuId = new String(message.getBody(),"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.err.println("-------------------ccccccccc:"+spuId);
        itemService.deleteItem(spuId);
    }
}
